/*
  Copyright © 2010  Camilo Costa Campos

      This file is part of Touché.

      Touché is free software: you can redistribute it and/or modify
      it under the terms of the GNU Lesser General Public License as published
      by the Free Software Foundation, either version 3 of the License, or
      (at your option) any later version.

      This program is distributed in the hope that it will be useful,
      but WITHOUT ANY WARRANTY; without even the implied warranty of
      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      GNU Lesser General Public License for more details.

      You should have received a copy of the GNU Lesser General Public License
      along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */

//Tags used in Touche:
//<ToucheText> "Text message to the other users" </ToucheText>
//<ToucheObject> </ToucheObject>
//<ToucheStartEditing> objId = int Id </ToucheStartEditing>
//<ToucheFinishEditing> objId = int Id </ToucheFinishEditing>

#include "writer.h"
#include <QXmlStreamWriter>
#include <QXmlStreamAttributes>
#include <QStringRef>
#include <iostream>

QString Writer::writeText(QString text)
{
    QString body;
    QXmlStreamWriter writer(&body);
    writer.writeTextElement("ChatText", text);
    return body;
}

QString Writer::lockElement(const QUuid &uuid)
{
    QString body;
    QXmlStreamWriter writer(&body);

    writer.writeStartElement("LockElement");
    writer.writeAttribute("uuid", uuid);
    writer.writeEndElement();
    return body;
}

QString Writer::unlockElement(const QUuid &uuid)
{
    QString body;
    QXmlStreamWriter writer(&body);

    writer.writeStartElement("UnlockElement");
    writer.writeAttribute("uuid", uuid);
    writer.writeEndElement();
    return body;
}



QString Writer::addElement(const QString &uuid, const QString &type, const QString &xmlData)
{
    QString data;
    QXmlStreamWriter writer(&data);
    writer.writeStartElement("Element");

    writer.writeAttribute("uuid", uuid);
    writer.writeAttribute("type", type);
    writer.writeCharacters(xmlData);

    writer.writeEndElement();

    qDebug(qPrintable(data));
    return data;
}

QString Writer::addLink(const QString &uuid1,const QString &uuid2)
{
    QString data;
    QXmlStreamWriter writer(&data);
    writer.writeStartElement("NewLink");

    writer.writeAttribute("uuid1", uuid1);
    writer.writeAttribute("uuid2", uuid2);

    writer.writeEndElement();

    qDebug(qPrintable(data));
    return data;
}


